public class Utils : GLib.Object
{
	/* Z pliku "utils.vala" będącego częścią kodu źródłowego Val(a)ide, opublikowanego na licencji GPL */
	public static Gtk.Button create_small_button (Gtk.Image image)
	{
		Gtk.Button button = new Gtk.Button ();
		button.set_relief (Gtk.ReliefStyle.NONE);
		/* don't allow focus on the close button */
		button.set_focus_on_click (false);

		/* make it as small as possible */
		Gtk.RcStyle rcstyle = new Gtk.RcStyle ();
		rcstyle.xthickness = rcstyle.ythickness = 0;
		button.modify_style (rcstyle);

		image.show ();

		button.add (image);

		/* Set minimal size */
		button.style_set += (s) => {
			int h, w;

			Gtk.icon_size_lookup_for_settings (s.get_settings (), Gtk.IconSize.MENU,
				                 out w, out h);
			s.set_size_request (w + 2, h + 2);
		};

		return button;
	}
	
	public static string get_mime_type (string filename) throws Error
	{
	  GLib.File file = File.new_for_path (filename);
	  GLib.FileInfo file_info = file.query_info ("standard::*", FileQueryInfoFlags.NONE, null);
	  return g_content_type_get_mime_type (file_info.get_content_type ());
	}
	
	public static void set_widget_warrnig_background (ref Gtk.Widget widget)
	{
		Gdk.Color? c;
		Gdk.Color.parse ("#D13F3F", out c); 
		widget.modify_base (Gtk.StateType.NORMAL, c);
	}
	
	public static void neg_color (ref Gdk.Color c)
	{
		c.red = ~c.red;
		c.green = ~c.green;
		c.blue = ~c.blue;
	}	
}
